const http = require('http');
const url = require('url');

function start(route) {
    function onRequest(request, responce) {
        let pathname = url.parse(request.url).pathname;
        console.log(`request for ${pathname} received`);
        console.log('pathname ==================================')
        route(pathname);
        responce.writeHead(200, {'content-type': 'text/plain'});
        // responce.end('Hello world!!')
        responce.write("Hello World");
        responce.end();
    }
    http.createServer(onRequest).listen(8080);
    console.log('service start')
}
exports.start = start;